package Reflection;

import java.lang.reflect.Constructor;

public class demo4 {
    public static void main(String[] args) throws NoSuchMethodException {
        //第一步先获取Class对象
        Class c = Cat.class;
        //第二步再获取指定的构造器
        //先获取无参的构造器
        Constructor c1 = c.getConstructor();
        System.out.println(c1.getName() + " => 参数有 " + c1.getParameterCount() + " 个");

        //获取有参的构造器
        Constructor c2 = c.getConstructor(String.class,int.class);
        System.out.println(c2.getName() + " => 参数有 " + c2.getParameterCount() + " 个");

    }
}
